package com.sugon.lambda;

import com.sugon.entity.Student;
import com.sugon.newInterface.Animal;
import com.sugon.newInterface.Filter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;

public class Java8 {

    public static void main(String[] args) {
        //创建一个对象，用接口中的静态方法
        Animal a = Animal.creatDog();
        //获得自然排序比较器
        Comparator<String> c1 = Comparator.naturalOrder();
        //获得倒序排序比较强
        Comparator<String> c2 = c1.reversed();
        List<String> list = Arrays.asList("luoy", "yangj", "fengch");
        list.sort(c1);

        /**
         * 遍历结合
         */
        list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });

        Filter f1 = new Filter<Student>() {
            @Override
            public boolean test(Student s) {
                return s.getAge() < 30;
            }
        };

        Filter<Student> f2 = (Student s) -> {
            return s.getAge() < 30;
        };

        Filter<Student> f3 = (Student s) -> s.getAge() < 30;
    }
}

